<include file="Product:header"/>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak={lanrain::$apikey}"></script>
<div class="main">
	<div class="p_map">
    <div id="container"></div>
        <script type="text/javascript">
        $(function(){
        	var wh = $(window).height();
        	var bh = $('body').height();
        	var mh = $('#container').css('height');
        	mh = mh.replace('px', '');
        	oh = bh - wh;
        	nmh = mh - oh;
        	$('#container').css('height', nmh+'px');
        
        	var sContent = function(id, name, imgsrc, address, tel){
        		return "<h2 style='margin:0 0 7px 0;padding:0 0'>"+name+"</h2>" + 
        		"<img style='float:right;margin:0px 0px 0px 4px' id='imgDemo' src='"+imgsrc+"' width='120' height='80' />" + 
        		"<p style='padding-right:10px'>地址："+address+"</p>" +
        		"<p style=''>电话："+tel+"</p>" +
        		"" +
        		"</div>";
        	}
        	var storeList = [{"id":"{lanrain::$thisCompany['id']}","name":"{lanrain::$thisCompany['name']}","logourl":"{lanrain::$thisCompany['logourl']}","address":"{lanrain::$thisCompany['address']}","tel":"{lanrain::$thisCompany['tel']}","longitude":"{lanrain::$thisCompany['longitude']}","latitude":"{lanrain::$thisCompany['latitude']}"}<volist name="branchStores" id="c">,{"id":"{lanrain::$c['id']}","name":"{lanrain::$c['name']}","logourl":"{lanrain::$c['logourl']}","address":"{lanrain::$c['address']}","tel":"{lanrain::$c['tel']}","longitude":"{lanrain::$c['longitude']}","latitude":"{lanrain::$c['latitude']}"}</volist>];
        	// 编写自定义函数,创建标注
        	function addMarker(point, content){
        	  var marker = new BMap.Marker(point);  // 创建标注
        	  map.addOverlay(marker);
        	  var infoWindow = new BMap.InfoWindow(content);
        	  marker.addEventListener("click", function(){          
        		   this.openInfoWindow(infoWindow);
        		   //图片加载完毕重绘infowindow
        		   document.getElementById('imgDemo').onload = function (){
        		       infoWindow.redraw();
        		   }
        		});
        	}
        	var map = new BMap.Map("container");
        	var point = new BMap.Point({lanrain::$thisCompany['longitude']}, {lanrain::$thisCompany['latitude']});
        	map.centerAndZoom(point, 15);
        	var user_marker = new BMap.Marker(point);  // 创建标注
        	map.addOverlay(user_marker);
            	   
        	for (var i = 0, l=storeList.length; i < l; i ++) {
        	  var point = new BMap.Point(storeList[i].longitude, storeList[i].latitude);
        	  var content = sContent(storeList[i].id,storeList[i].name,storeList[i].logourl,storeList[i].address,storeList[i].tel);
        	  addMarker(point, content);
        	}

        });
        </script>
	</div>
</div>
</body>
</html>